home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dicecache / subs.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  1KB  |  69 lines

  1. /*
  2.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  3.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  4.  *    DICE-LICENSE.TXT.
  5.  */
  6.  
  7. /*
  8.  *  SUBS.C
  9.  */
  10.  
  11. #include "defs.h"
  12.  
  13. Prototype void xprintf(const char *, ...);
  14. Prototype char *MyFilePart(const char *);
  15. Prototype char *MyPathPart(const char *);
  16. Prototype long MySameLock(BPTR, BPTR);
  17.  
  18. void
  19. xprintf(ctl, ...)
  20. const char *ctl;
  21. {
  22.     va_list va;
  23.  
  24.     va_start(va, ctl);
  25.     vfhprintf(Output(), ctl ,va);
  26.     va_end(va);
  27. }
  28.  
  29. char *
  30. MyFilePart(ptr)
  31. const char *ptr;
  32. {
  33.     short i;
  34.  
  35.     for (i = strlen(ptr) - 1; i >= 0; --i) {
  36.     if (ptr[i] == '/' || ptr[i] == ':')
  37.         break;
  38.     }
  39.     return(ptr + i + 1);
  40. }
  41.  
  42. char *
  43. MyPathPart(ptr)
  44. const char *ptr;
  45. {
  46.     const char *p = MyFilePart(ptr);
  47.  
  48.     if (p > ptr && p[-1] == '/')
  49.     --p;
  50.     return(p);
  51. }
  52.  
  53. long
  54. MySameLock(l1, l2)
  55. BPTR l1;
  56. BPTR l2;
  57. {
  58.     FileLock *lock1 = BTOC(l1);
  59.     FileLock *lock2 = BTOC(l2);
  60.  
  61.     if (lock1->fl_Volume == lock2->fl_Volume) {
  62.     if (lock1->fl_Key == lock2->fl_Key)
  63.         return(LOCK_SAME);
  64.     return(LOCK_SAME_HANDLER);
  65.     }
  66.     return(LOCK_DIFFERENT);
  67. }
  68.  
  69.